<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<script type="text/javascript">
	$(function() {

		// 登录dialog
		$('#index_loginDialog').dialog({
			title : '登录',
			closable : false,
			modal : true,
			buttons : [ {
				text : '注册',
				handler : function() {
					$('#index_regDialog').dialog('open');
				}
			}, {
				text : '登录',
				handler : function() {
					$("#index_loginForm").form('submit');
				}
			} ]
		});

		$("#index_loginForm").form({
			url : '${pageContext.request.contextPath}/userAction!login.action',
			onsubmit : function() {

			},
			success : function(r) {
				var obj = jQuery.parseJSON(r);

				if (obj.success) {
					$("#index_loginDialog").dialog("close");
				}
				$.messager.show({
					title : '提示',
					msg : obj.msg
				});
			}
		});
		
		window.setTimeout(function() {
			$("#index_loginForm input[name=name]").focus();
		}, 0);
		
		$("#index_loginForm input").bind("keyup", function(event) {
			if (event.keyCode == "13") {
				$("#index_loginForm").submit();
			}
		});
	});
</script>
<div id="index_loginDialog" class="easyui-dialog" style="width:250px">
	<form id="index_loginForm" method="post">
		<table>
			<tr>
				<th>登录名</th>
				<td><input name="name" class="easyui-validatebox" /></td>
			</tr>
			<tr>
				<th>密码</th>
				<td><input name="pwd" type="password"
					class="easyui-validatebox" /></td>
			</tr>
		</table>
	</form>
</div>
